package com.lgt_enterprise_android.view.pages.b.workors;

import android.os.Bundle;
import android.widget.TextView;

import com.alibaba.fastjson.JSONObject;
import com.lgt_enterprise_android.R;
import com.lgt_enterprise_android.base.BaseActivity;
import com.lgt_enterprise_android.utils.BasicHttp;
import com.lgt_enterprise_android.utils.CommonUtil;
import com.lgt_enterprise_android.utils.HttpManager;

public class WorkerDetailActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_worker_detail);
        String staffID=getIntent().getStringExtra("staff_id");

        HttpManager.getStaffDetail(mContext, staffID, new BasicHttp.IMyCallBack() {
            @Override
            public void onResponse(Object resonseObj) {
                JSONObject jo=(JSONObject)resonseObj;

                JSONObject JOWorkerDO=jo.getJSONObject("workerDTO");

                setText(R.id.txt_name,JOWorkerDO.getString("name"));
                setText(R.id.txt_age,JOWorkerDO.getString("age"));
                setText(R.id.txt_gender, CommonUtil.getGenderStr(JOWorkerDO.getIntValue("gender")));


                setText(R.id.txt_mobile,JOWorkerDO.getString("phoneNumber"));

            }

            @Override
            public void onFailure(String mes) {

            }
        });
    }

    private void setText(int viewId,String txt){
        ((TextView)findViewById(viewId)).setText(txt);
    }
}
